<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            margin: 0;
            padding: 0;
        }
        
        .parent {
            height: 500px;
            width: 500px;
            background-color: pink;
            margin: 0 auto;
            /* text-align: center;
            line-height: 500px; */
            /* position: relative; */

            /* 6.1flex实现 */
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .child {
            width: 300px;
            height: 300px;
            background-color: aquamarine;
            /* 1. 水平（子变行内块，父设置text-align）,垂直（父设置行高，子设置vertical-align） */
            /* display: inline-block;
            vertical-align: middle; */

            /* 2.子绝父相 :  top + left函数计算固定的距离 */
            /* position:absolute;
            top : calc(50% - 150px);
            left : calc(50% - 150px); */

            /* 3.子绝父相 ： top + left + margin */
            /* position: absolute;
            top : 50%;
            left: 50%;    
            margin-top: -150px;
            margin-left: -150px; */

            /* 4.子绝父相 ： 四个方位拉伸 + margin */
            /* position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            margin: auto; */

            /* 5.子相对定位 + top + left + 偏移 */
            /* position: relative;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%); */

            /* 6.2 父flex + 子margin */
            /* margin: auto; */
        }
    </style>
</head>

<body>
    <div class="parent">
        <div class="child"></div>
    </div>
</body>
</html>
</body>
</html>